package com.hb.common.enums;

/**
 *
 *
 * @author hb
 * @date 2023/04/25
 */
public enum Oauth2GrantType {

    /**
     * 客户端
     */
    CLIENT_CREDENTIALS("client_credentials", "客户端"),
    PASSWORD("password", "用户密码"),
    UNKNOWN("unknown", "未知");

    private String code;

    private String desc;

    Oauth2GrantType(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String code() {
        return this.code;
    }

    public String desc() {
        return this.desc;
    }

    public static Oauth2GrantType codeOf(String code) {
        for(Oauth2GrantType oauth2GrantType : Oauth2GrantType.values()) {
            if(oauth2GrantType.code().equals(code)) {
                return oauth2GrantType;
            }
        }
        return UNKNOWN;
    }
}
